<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

<h1>Blog</h1>

<c:if test="${pageContext.request.userPrincipal != null && pageContext.request.userPrincipal.name == user.username}">
	<a href="<c:url value="/users/${user.id}/blogs/edit/${blog.id}" />">Edit Blog</a>
</c:if>

<div id="blogs">
	<h1><c:out value="${blog.title}" escapeXml="true" /><br/></h1>		
</div>
<div id="blogs">
	<c:out value="${blog.keywords}" escapeXml="true" /><br/>		
</div>
<div id="blogs">	 
	<c:out value="${blog.catalog.name}" escapeXml="true" /><br/>
</div>
<div id="blogs">			
	${blog.replyCount}<br/>
	${blog.createdDate}<br/>
	${blog.modifyDate}<br/>
	${blog.modifierId}<br/>
</div>
<div id="blogs">	
	${blog.content}<br/>
</div>


<div id="blogCommentResults">
	<table class="summary">
		<thead>
			<tr>
				<th>UserId</th>
				<th>date</th>
				<th>Content</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="blogComment" items="${blogCommentList}">
				<tr>
					<td>${blogComment.userId}</td>
					<td>${blogComment.createdDate}</td>
					<td>${blogComment.content}</td>
				</tr>
			</c:forEach>
			<c:if test="${empty blogCommentList}">
				<tr>
					<td colspan="3">No hotels found</td>
				</tr>
			</c:if>
		</tbody>
	</table>
</div>	

<c:if test="${pageContext.request.userPrincipal != null}">
<c:url var="blogCommentUrl" value="/blogcomments/persist"/>
<form:form modelAttribute="blogComment" action="${blogCommentUrl}" method="post" cssClass="inline">
    <spring:hasBindErrors name="blogComment">
			<div class="error">
				<spring:bind path="blogComment.*">
					<c:forEach items="${status.errorMessages}" var="error">
						<span><c:out value="${error}"/></span><br>
					</c:forEach>
				</spring:bind>
			</div>
	</spring:hasBindErrors>
	<fieldset>
		<div class="span-8">
			<form:hidden id="blogId" path="blog.id"/>
			<form:textarea id="content" path="content" style="width:680px;height:200px;"/><br/>
			<button id="proceed" type="submit">OK</button>
		</div>
	</fieldset>
</form:form>
<script type='text/javascript'>
<!--
	var editor;
	$(document).ready(function(){
		editor = KindEditor.create('textarea[name="content"]',{
			id : 'content',
			resizeMode : 1,
			shadowMode : false,
			allowPreviewEmoticons : false,
			allowUpload : true,
			syncType : 'form',
			urlType : 'domain',
			cssPath : '<c:url value="/resources/js/plugins/code/prettify.css" />',
			uploadJson : '<c:url value="/image/upload" />',
			items : ['bold', 'italic', 'underline', 'strikethrough', 'removeformat','|',
'formatblock', 'fontname', 'fontsize','|',
'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent','|',
'link', 'unlink', 'emoticons', 'image', 'flash', '|',
'selectall','source' ,'about']
		});
	});
//-->
</script>
</c:if>


